import Vue from 'vue'
import VueRouter from 'vue-router'


Vue.use(VueRouter)

// 直接加载主页
import LayoutView from '../LayoutView.vue'
const routes = [
  {
    path: '/',
    redirect: '/index', //打开页面就想显示首页
  },
  {
    path: '/',
    name: 'layout',
    component: LayoutView,
    children: [
      {
        path: 'index',
        name: 'home',
        component: () => import('../views/HomeView.vue')
      },
      {
        path: '/My',
        component: () => import('../views/MyView.vue'),
        name: 'personal'
      },
      {
        path: '/CartView',
        component: () => import('../views/CartView.vue'),
        name: 'cart'
      },
      {
        path: '/ClassificationView',
        component: () => import('../views/ClassificationView.vue'),
        name: 'classification'
      },
    ]
  },
  {
    path: '/login',
    component: () => import('../views/LoginView.vue'),
    name: 'login'
  },
  {
    path: '/search',
    component: () => import('../views/SearchView.vue'),
    name: 'search'
  },
  {
    path: '/EmptyView',
    component: () => import('../views/EmptyView.vue'),
    name: 'empty'
  },
  {
    path: '/register',
    component: () => import('../views/RegisterView.vue'),
    name: 'register'
  },
  {
    path: '/detail',
    component: () => import('../views/DetailView.vue'),
    name: 'detail'
  },

]

const router = new VueRouter({
  routes
})

export default router
